import { Component, memo, PropsWithChildren, useState } from "react";
import { useLoad } from "@tarojs/taro";
import { View } from "@tarojs/components";
import request from "@/services/index.ts";
import styles from "./index.module.scss";

type InfoTyp=Array<{
   ename: string,
   link: string,
   describee: string,
   technology: string,
   responsibility: string,
   problem: string,
   id:number
  }>;
const Index = memo(function () {
  const [getProject, setgetProject] = useState<InfoTyp>([]);
  useLoad(() => {
    let obj={
      link:Taro.getStorageSync('link'),
      eid:Taro.getStorageSync('eid')
   }
    request.get("/promotion/project", obj).then((res) => {
      setgetProject(res.data.projects);
    });
  });
  return (
    <View  className={`${styles.page} backgroundImg`}>
    <View  className={`${styles.cards}`}>
      {getProject.map((item)=>{
        return (
          <View className={`${styles.card}`} key={item.id}>
            <View className={`${styles.projectName} ${styles.title}`} >{item.ename}{item.link&&<span>(链接：{item.link})</span>}</View>
            <View><span className={`${styles.title}`} >项目描述：</span> {item.describee}</View>
            <View><span className={`${styles.title}`} >技术栈：</span> {item.technology}</View>
            <View><span className={`${styles.title}`} >责任描述：</span> {item.responsibility}</View>
            {item.problem&&<View><span className={`${styles.title}`} >主动性：</span> {item.problem}</View>}
        </View>
        )
      })}
    </View>
    </View>
  );
});

export default Index;
